<?php
if(isset($_POST['submit'])){
	require 'class.imageupload.php';
	//$image = new ImageUloader($max_size, $max_width, $max_height, $upload_dir)
	$image = new ImageUploader(30000, '../img/'); //1. maximum image size in kb(kilo byte), 2. maximum image width
																//3. maximum image height, 4. upload dir
	$image->setImage('foto'); //name of your input image field name
	
	if(!$image->checkSize()) //check image size
		$errors[] = "File size is Big";
		
	if(!$image->checkExt()) //check image extension
		$errors[] = "File ext is not supported";
		
	if(!isset($errors)){
		$image->setImageName('foto');
		$image->deleteExisting();
		$image->upload();
		
		echo "<h2>Avatar Changed Successfully</h2>";
		
	}
	else{
		echo "<h2>You must correct the errors to proceed</h2><br>";
		print_r($errors);
	}
}
?>
